import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入
// @符号在脚手架里代表src目录
// 如果你要找的是index.js或者index.vue，都可以省略不写
// 他会默认找里面的index.js找不到再找index.vue
import layout from '@/views/layout'
import home from '@/views/home'
import search from '@/views/search'
import play from '@/views/play'

Vue.use(VueRouter)

const routes = [
  // 路由重定向
  { path: '/', redirect: '/layout/home' },
  {
    name: 'layout',
    path: '/layout',
    component: layout,
    // 这个组件的子路由
    children: [
      // 现在需要给home和search两个路由打标记
      // 打标记就是通过 `meta` 属性来打
      { 
        name: 'home', 
        path: 'home', 
        component: home, 
        meta: {
          title: '首页'
        } 
      },
      { 
        name: 'search', 
        path: 'search', 
        component: search,
        meta: {
          title: '搜索'
        }
       },
    ]
  },

  { name: 'play', path: '/play', component: play },
]

const router = new VueRouter({
  routes
})

export default router
